package cn.edu.neusoft.wuguangsheng.flowerimpression.activity;

import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;

import cn.edu.neusoft.wuguangsheng.flowerimpression.R;
import cn.edu.neusoft.wuguangsheng.flowerimpression.bean.SuccessBean;
import cn.edu.neusoft.wuguangsheng.flowerimpression.listener.TListener;
import cn.edu.neusoft.wuguangsheng.flowerimpression.model.UpdateMyOrderCommentModel;

public class UpdateMyOrderCommentActivity extends BaseActivity {

    private String orcid,content;

    ImageView updatemyordercomment_fh;
    EditText updatemyordercomment_content;
    Button updatemyordercomment_btn;
    @Override
    void initView() {
        setLayout_file(R.layout.activity_update_my_order_comment);
        orcid = getIntent().getStringExtra("orcid");
        content = getIntent().getStringExtra("content");
        updatemyordercomment_fh = (ImageView)findViewById(R.id.updatemyordercomment_fh);
        updatemyordercomment_content = (EditText)findViewById(R.id.updatemyordercomment_content);
        updatemyordercomment_btn = (Button)findViewById(R.id.updatemyordercomment_btn);
        updatemyordercomment_content.setText(content);
    }

    @Override
    void initEvent() {
        updatemyordercomment_fh.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        updatemyordercomment_btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String contents = updatemyordercomment_content.getText().toString().trim();
                if (content.equals("")){
                    Toast.makeText(UpdateMyOrderCommentActivity.this,"内容不能为空",Toast.LENGTH_SHORT).show();
                }
                else {
                    UpdateMyOrderCommentModel updateMyOrderCommentModel = new UpdateMyOrderCommentModel();
                    updateMyOrderCommentModel.updateMyOrderComment(orcid, contents, new TListener<SuccessBean>() {
                        @Override
                        public void onResponse(SuccessBean successBean) {
                            if (successBean.getSuccess().equals("1")){
                                Toast.makeText(UpdateMyOrderCommentActivity.this,"修改成功",Toast.LENGTH_SHORT).show();
                                finish();
                            }
                            else {
                                Toast.makeText(UpdateMyOrderCommentActivity.this,"修改失败",Toast.LENGTH_SHORT).show();
                            }
                        }

                        @Override
                        public void onFail(String msg) {
                            Toast.makeText(UpdateMyOrderCommentActivity.this,"修改失败",Toast.LENGTH_SHORT).show();
                        }
                    });
                }
            }
        });

    }

    @Override
    void initDate() {

    }
}
